package com.zxmr.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;

import com.zxmr.component.SystemConstant;

public class ResourceLoader{

	String file;
	Map<String,String> resources = new HashMap<String,String>();
	
	public ResourceLoader(String file) throws Exception {
		this.file = file;
	}


	public void init() {
		File f = new File(SystemConstant.getBasedir()+file);
		BufferedReader reader = null;
		try
		{
			reader = new BufferedReader(new FileReader(f));
			String tempString = null;
			while((tempString = reader.readLine()) != null)
			{
				if(tempString.contains("="))
				{
					String key = tempString.substring(0,tempString.indexOf("="));
					String value = tempString.substring(tempString.indexOf("=")+1, tempString.length());
					resources.put(key, value);
				}
			}
		}catch(Exception e)
		{
			e.printStackTrace();
		}
		
	}
	public String get(String key)
	{
		return resources.get(key);
	}
}
